package com.yida.gwj.config.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.InnerAuth;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.gwj.config.domain.dto.GwjConfNoticePageDTO;
import com.yida.gwj.config.domain.request.GwjConfNoticeSaveRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yida.gwj.config.domain.GwjConfNotice;
import com.yida.gwj.config.service.IGwjConfNoticeService;

/**
 * 公维金信息公示Controller
 * 
 * @author ruoyi
 * @date 2023-06-02
 */
@RestController
@RequestMapping("/config/notice")
@Api(tags = "公维金信息公示")
public class GwjConfNoticeController extends BaseController
{
    @Autowired
    private IGwjConfNoticeService gwjConfNoticeService;

    /**
     * 查询公维金信息公示列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "分页查询",response = GwjConfNoticePageDTO.class)
    public TableDataInfo list()
    {
        startPage();
        List<GwjConfNoticePageDTO> list = gwjConfNoticeService.selectGwjConfNoticeList();
        return getDataTable(list);
    }

    /**
     * 获取公维金信息公示详细信息
     */
    @GetMapping(value = "/getInfo/{id}")
    @ApiOperation(value = "详情")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gwjConfNoticeService.selectGwjConfNoticeById(id));
    }

    /**
     * 新增公维金信息公示
     */
//    @RequiresPermissions("config:notice:add")
    @Log(title = "公维金信息公示", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增")
    public AjaxResult add(@Validated @RequestBody GwjConfNoticeSaveRequest saveRequest)
    {
        return toAjax(gwjConfNoticeService.save(saveRequest));
    }

    /**
     * 修改公维金信息公示
     */
    @RequiresPermissions("config:notice:edit")
    @Log(title = "公维金信息公示", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改")
    public AjaxResult edit(@RequestBody GwjConfNotice gwjConfNotice)
    {
        return toAjax(gwjConfNoticeService.updateGwjConfNotice(gwjConfNotice));
    }

    /**
     * 删除公维金信息公示
     */
    @RequiresPermissions("config:notice:remove")
    @Log(title = "公维金信息公示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gwjConfNoticeService.deleteGwjConfNoticeByIds(ids));
    }

    /**
     * 判断业务是否公示
     */
    @GetMapping("/judgeExist/{bizId}")
    @ApiOperation("判断业务是否公示")
    public AjaxResult judgeExist(@PathVariable("bizId") Long bizId){
        return AjaxResult.success(gwjConfNoticeService.judgeExist(bizId));
    }
}
